#pragma once
#include "DSlider.h"
#include "../DWorld.h"
#include "../DVector3.h"
#include "DJointGroup.h"

namespace Skill
{
	namespace Ode
	{
		namespace Joints
		{		
			void DSlider::CollectManagedMemory()
			{				
				Axis = nullptr;				
				DJoint::CollectManagedMemory();
			}
			DSlider::DSlider(DWorld^ world , DJointGroup^ group)
				:DJoint(world,group)
			{
				dWorldID w = world? world->_This : NULL;
				dJointGroupID g = group? group->_This : NULL;
				_SetPointer(dJointCreateSlider(w,g),true);
			}

			DVector3^ DSlider::Axis::get()
			{
				if(!_Axis)
					_Axis = gcnew DVector3();
				dJointGetSliderAxis(_This,_Axis->_This);
				return _Axis;
			}
			void DSlider::Axis::set(DVector3^ value)
			{
				dJointSetSliderAxis(_This,value->_This[0],value->_This[1],value->_This[2]);
			}


			void DSlider::SetAxisDelta(dReal x, dReal y, dReal z, dReal ax, dReal ay, dReal az)
			{
				dJointSetSliderAxisDelta(_This,x, y, z, ax, ay, az);
			}
			void DSlider::SetAxisDelta(DVector3^ p, DVector3^ d)
			{
				dJointSetSliderAxisDelta(_This,p->_This[0], p->_This[1], p->_This[2], d->_This[0], d->_This[1], d->_This[2]);
			}

			void DSlider::SetParam(DJointParameters parameter, dReal value)
			{
				dJointSetSliderParam(_This,(int)parameter, value);
			}

			dReal DSlider::GetParam(DJointParameters parameter)
			{
				return dJointGetSliderParam(_This,(int)parameter);
			}
			void DSlider::AddForce(dReal force)
			{
				dJointAddSliderForce(_This,force);
			}
			dReal DSlider::Position::get()
			{
				return dJointGetSliderPosition(_This);
			}
			dReal DSlider::PositionRate::get()
			{
				return dJointGetSliderPositionRate(_This);
			}
		}
	}
}